-- Sets up the script's main chat commands table --
Hyperion.ChatCommands = { }

-- Handles OOC chatting --
function Hyperion.OOCTalk( text )
	for k, v in pairs( player.GetAll() ) do
		v:ChatPrint( text )
	end
end

-- Handles IC chatting --
function Hyperion.ICTalk( text, position, size )
	for k, v in pairs( ents.FindInSphere( position, size ) ) do
		if ( v:IsPlayer() ) then
			v:ChatPrint( text )
		end
	end
end

-- Handles chatting in general --
function GM:PlayerSay( ply, text )
	local exp = string.Explode( " ", text )

	if ( Hyperion.ChatCommands[ exp[ 1 ] ] ) then
		local len = string.len( text )
		local sub = string.len( exp[ 1 ] ) + 2

		Hyperion.ChatCommands[ exp[ 1 ] ]( ply, exp, string.sub( text, sub, len ) )

		return ""
	else
		Hyperion.ICTalk( ply:Nick() .. " says: " .. text, ply:GetPos(), 250 )

		return ""
	end
end